package com.tnsw.coreutils.database;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;

import android.util.Log;

public class RecordBase {

	public int primarykey;
	
	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		
		Class c = this.getClass();
		sb.append(this.getClass().getName() + "[");
		
		try {
			int i = 0;
			for (Field field : c.getFields()) {
				
				if (field.getModifiers() == Modifier.PUBLIC) {
					if (i > 0) {
						sb.append(", ");
					}
					
					String value = "nUll";
					if (field.get(this) != null) {
						value = field.get(this).toString();
					}
					
					sb.append(field.getName() + "={" + value + "}");
					
					i += 1;
				}
				

			}			
		} catch (Exception e) {
			Log.e("RecordBase", "toString() - " + e.toString(), e);
		}
		
		sb.append("]");

		
		return(sb.toString());
	}
}

